{% extends 'TopxiaWebBundle:Card:layout.html.twig' %}

{% set main_nav = 'cards' %}
{% set script_controller = 'topxiawebbundle/controller/card/index' %}

{% block main_body %}
  {% if app.request.cookies.get('modalOpened') == 1 %}
    <a href="#modal" class="receive-modal hidden" data-toggle="modal" data-url="{{ path('card_info',{'cardType':app.request.query.get('cardType'),'cardId':app.request.query.get('cardId')}) }}" ><span class=""></span></a>
  {% endif %}
  <div class="clearfix mbl">
    <ul class="nav nav-pills inline-block">
      <li role="presentation" {% if app.request.query.get('cardType')=='' or app.request.query.get('cardType')=='coupon' %} class="active"{% endif %}><a href="{{ path('my_cards',{ cardType:''}) }}">优惠券</a></li>
    {% if is_plugin_installed("MoneyCard") %}
      <li role="presentation" {% if app.request.query.get('cardType')=='moneyCard' %} class="active"{% endif %}><a href="{{ path('my_cards',{ cardType:'moneyCard'}) }}">学习卡</a></li>
    {% endif %}
    </ul>

    <div class="pull-right btn-group">
    {% if is_plugin_installed("MoneyCard") %}
        <a role="filter-change" class="btn btn-default {% if app.request.query.get('filter') == '' or app.request.query.get('filter') == 'all' %}btn-primary{% endif %}" data-url='{{ path('my_cards',{cardType:app.request.query.get('cardType'),filter:''}) }}'>全部</a>
        <a role="filter-change" class="btn btn-default {% if app.request.query.get('filter') == 'useable' %}btn-primary{% endif %}" data-url='{{ path('my_cards',{cardType:app.request.query.get('cardType'),filter:'useable'}) }}'>未使用</a>
        <a role="filter-change" class="btn btn-default {% if app.request.query
        .get('filter') == 'used' %}btn-primary{% endif %}" data-url='{{ path('my_cards',{cardType:app.request.query.get('cardType'),filter:'used'}) }}'>已使用</a>
        <a role="filter-change" class="btn btn-default {% if app.request.query.get('filter') == 'outdate' %}btn-primary{% endif %}" data-url='{{ path('my_cards',{cardType:app.request.query.get('cardType'),filter:'outdate'}) }}'>已过期</a>
      {% endif %}

      {% if is_plugin_installed("MoneyCard") and app.request.query.get('cardType') == "moneyCard" %}
        <a role="filter-change" class="btn btn-default {% if app.request.query.get('filter') == 'invalid' %}btn-primary{% endif %}" data-url='{{ path('my_cards',{cardType:app.request.query.get('cardType'),filter:'invalid'}) }}'>已作废</a> 
      {% endif %}
    </div>
  </div>
  <div class="card-pack-list">
    <div class="row">
      {% if setting('coin.coin_enabled') != 0 or app.request.query.get('cardType') != 'moneyCard' %}
        {% if cards is not null %}
          {% for card in cards %}
            <div class="col-lg-4 col-md-6 col-sm-6">
              {% if card.cardType == 'coupon'%}
                {% include 'TopxiaWebBundle:Card:coupon-'~card.status~'.html.twig' with {cardDetail:cardDetails[card.cardId]} %}
              {% endif %}
              {% if card.cardType == 'moneyCard' and is_plugin_installed('moneyCard') %}  
                {% include 'TopxiaWebBundle:Card:moneycard-'~card.status~'.html.twig' with {cardDetail:cardDetails[card.cardId]} %}
              {% endif %}
            </div>
          {% endfor %}
        {% else %}
          <div class="empty">没有搜索到符合条件的{% if app.request.query.get('cardType')=='' or app.request.query.get('cardType')=='coupon' %}优惠券{% else %}学习卡{% endif %}</div>
        {% endif %}
      {% else %}
        <div class="empty">网站没有开启{{setting('coin.coin_name')|default('虚拟币')}}功能,学习卡功能暂时没法使用</div>
      {% endif %}
    </div>
  </div>
{% endblock %}